package com.sbl.bajw.pc.action;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.sbl.bajw.common.web.JsonResultUtil;
import com.sbl.bajw.common.web.RequestUnit;
import com.sbl.bajw.pc.model.DeptModel;
import com.sbl.bajw.pc.service.DeptPrivilegeService;

@Controller
@RequestMapping("/DeptPrivilege")
public class DeptPrivilegeAction {
	
	@Resource
	private DeptPrivilegeService service;
	
	/**
	 * 跳转到数据权限管理用户列表中
	 * @作者：罗琦
	 * @return
	 */
	@RequestMapping(value = "/userList")
	public ModelAndView userList(){
		ModelAndView mv = new ModelAndView("/view/manager/DeptPrivilege/userList");
		return mv;
	}
	
	@RequestMapping(value = "/manager")
	public ModelAndView manager(){
		List<HashMap<String, String>> businessTypes = service.getBusinessType();
		List<DeptModel> depts = service.getOrgManagerListAll();
		RequestUnit.setAttr("deptModels", depts);
		RequestUnit.setAttr("businessTypes", businessTypes);
		ModelAndView mv = new ModelAndView("/view/manager/DeptPrivilege/manager");
		return mv;
	}
	
	@RequestMapping(value = "/updatePrivilege")
	public @ResponseBody String updatePrivilege(){
		service.updatePrivilege();
		return JsonResultUtil.Success();
	}
}
